package com.hexacta.hrs.domain.mentoring;

import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.vectrics.common.db.AbstractRecordObject;

/**
 * Class that represents a theme
 * 
 * @author vschimpf
 */
public class Theme extends AbstractRecordObject {

    private String name;

    private ThemeTypes type;

    private PriorityTypes priority;

    public String getName() {
        return name;
    }

    public String getEscapedName() {
        return StringEscapeUtils.escapeHtml(name);
    }

    public String getUnescapedName() {
        return StringEscapeUtils.unescapeHtml(name);
    }

    public void setName(final String name) {
        this.name = name;
    }

    public ThemeTypes getType() {
        return type;
    }

    public void setType(final ThemeTypes type) {
        this.type = type;
    }

    public PriorityTypes getPriority() {
        return priority;
    }

    public void setPriority(final PriorityTypes priority) {
        this.priority = priority;
    }

    /**
     * Este m�todo crea una nueva instancia y copia todas las propiedades
     */
    public Theme copy() {
        Theme copyTheme = new Theme();
        copyTheme.setName(getName());
        copyTheme.setType(getType());
        copyTheme.setPriority(getPriority());
        copyTheme.setId(getId());
        return copyTheme;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o)
            return true;
        if (o == null)
            return false;
        if (!(o instanceof Theme))
            return false;
        final Theme other = (Theme) o;

        EqualsBuilder eb = new EqualsBuilder();
        eb.append(getName(), other.getName());
        eb.append(getType(), other.getType());
        eb.append(getPriority(), other.priority);
        if (getId() != null) {
            eb.append(getId(), other.getId());
        }

        return eb.isEquals();
    }

    @Override
    public int hashCode() {
        HashCodeBuilder hcb = new HashCodeBuilder();
        hcb.append(getName());
        hcb.append(getType());
        hcb.append(getPriority());
        if (getId() != null) {
            hcb.append(getId());
        }

        return hcb.toHashCode();
    }

}